package com.lenovo.lcdm.type.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lenovo.lcdm.common.enums.DeleteFlagEnum;
import com.lenovo.lcdm.type.entity.TypeLocalAttributeSort;
import com.lenovo.lcdm.type.mapper.TypeLocalAttributeSortMapper;
import com.lenovo.lcdm.type.service.TypeLocalAttributeSortService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
* @author xujing30
* @description 针对表【type_local_attribute_sort】的数据库操作Service实现
* @createDate 2024-01-03 16:33:33
*/
@Service
public class TypeLocalAttributeSortServiceImpl extends ServiceImpl<TypeLocalAttributeSortMapper, TypeLocalAttributeSort>
    implements TypeLocalAttributeSortService{

    @Override
    public Map<Long, Map<Long,Long>> findByTypeId(List<Long> typeIds) {
        LambdaQueryWrapper<TypeLocalAttributeSort> localAttributeSortQw = new LambdaQueryWrapper<>();
        localAttributeSortQw.eq(TypeLocalAttributeSort::getDeleted, DeleteFlagEnum.NO.getValue()).in(TypeLocalAttributeSort::getTypeId, typeIds);
        List<TypeLocalAttributeSort> listSort = this.list(localAttributeSortQw);
        return listSort.stream().collect(Collectors.groupingBy(TypeLocalAttributeSort::getTypeId,Collectors.toMap(TypeLocalAttributeSort::getGlobalAttributeId,
                TypeLocalAttributeSort::getSortId)));
    }
}




